package smedi.ismedi.mobile.bff.controller.dataMiddlePlatform;

import com.smedi.ismedi.inmail.api.feign.RemoteDataMiddlePlatformFeignApi;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * 数据中台
 *
 * @author xuyuanqiao
 * @date 2021/09/02
 */
@Slf4j
@Api(value = "数据中台接口", tags = {"数据中台接口"})
@RequestMapping(value = "/mobilebff/v1/dataMiddlePlatForm")
@RestController
@AllArgsConstructor
public class WeatherController {
    private final RemoteDataMiddlePlatformFeignApi remoteDataMiddlePlatformFeignApi;

    /**
     * 查询天气
     *
     * @param cityName 城市名字
     * @param date     日期
     * @return ResponseData<String> 天气
     */
    @ApiOperation(httpMethod = "GET", value = "获取天气")
    @GetMapping(value = "/weather")
    ResponseData<String> getWeather(@RequestParam(value = "cityName") String cityName,
                                    @RequestParam(value = "date") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
        
        return remoteDataMiddlePlatformFeignApi.getWeather(cityName,date);
    }
}
